<%-- 
    Document   : EditCanhan
    Created on : Dec 19, 2013, 10:08:24 AM
    Author     : Huyen
--%>

<%@page import="businesscard.DAO.UserDAO"%>
<%@page import="bc.entity.User"%>
<%@page import="bc.entity.Thanhpho"%>
<%@page import="businesscard.DAO.ThanhphoDAO"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" href="css/style.css" type="text/css"/>
        <link rel="stylesheet" href="css/bocuc.css" type="text/css"/>
        <link rel="stylesheet" href="css/testcss.css" type="text/css"/>
        <link rel="stylesheet" href="css/mystyle.css" type="text/css"/>
        <link rel="stylesheet" href="css/botoncss.css" type="text/css"/>
        <link rel="stylesheet" href="css/trangcanhan.css" type="text/css"/>
        <title>JSP Page</title>
        <script>
            var xmlhttp;
             function check_email()
            {
                xmlhttp = GetXmlHttpObject();

                if (xmlhttp == null)
                {
                    alert("Your browser does not support Ajax HTTP");
                    return;
                }
                var email = document.getElementById("txtEmail").value;
                if (email.trim() === "") {
                    document.getElementById("ck_email").innerHTML = "<p style='color:red'>Email không được bỏ trống!</p>";
                }
                else {
                    var url = "kiemtra_email.jsp";
                    url = url + "?email=" + email;

                    xmlhttp.onreadystatechange = getOutputEmail;
                    xmlhttp.open("GET", url, true);
                    xmlhttp.send(null);
                }
            }
             function getOutputEmail() {
                if (xmlhttp.readyState == 4 || xmlHttp.readyState == "complete")
                {
                    document.getElementById("ck_email").innerHTML = xmlhttp.responseText;
                }
            }
            function getOutputQuan()
            {
                if (xmlhttp.readyState == 4 || xmlHttp.readyState == "complete")
                {
                    document.getElementById("txtQuanhuyen").innerHTML = xmlhttp.responseText;
                }
            }
            function get_Quanhuyen() {
                xmlhttp = GetXmlHttpObject();

                if (xmlhttp == null)
                {
                    alert("Your browser does not support Ajax HTTP");
                    return;
                }
                var thanhpho = document.getElementById("txtThanhpho").value;

                var url = "getQuanhuyen.jsp";
                url = url + "?thanhpho=" + thanhpho;

                xmlhttp.onreadystatechange = getOutputQuan;
                xmlhttp.open("GET", url, true);
                xmlhttp.send(null);
            }
            function GetXmlHttpObject()
            {
                if (window.XMLHttpRequest)
                {
                    return new XMLHttpRequest();
                }
                if (window.ActiveXObject)
                {
                    return new ActiveXObject("Microsoft.XMLHTTP");
                }
                return null;
            }
        </script>
    </head>
    <body>
        <div class="bodypage">
            <!phan dau cua trang>
            <div class="top">
                <%@include file='header.jsp'%>
            </div>
            <!phan search>
            <div class="khoangcachtrang">
                <div class="searchgroup">

                    <%@include file='search.jsp' %> 
                    <div class="chontimkiem">
                        <a href="timkiemnangcao.jsp">Tìm Kiếm Nâng Cao</a>
                    </div>

                </div>
            </div>
            <!phan giua trang >
            <div class="centerpage">
                <div class="leftsite">
                    <div class="menuweb">
                        <%@include file='menuleft.jsp' %>
                    </div>
                </div>
                <div class="content">
                    <div class="khoangtrang"></div>
                    <div class="thongtin">
                        <div style="font-size: 26px; font-weight: bold;padding-top: 10px;">THÔNG TIN CÁ NHÂN</div>
                        <form action="UserController" method="post">
                        <%
                             User user = (User) request.getSession().getAttribute("USER");
                            String username = user.getUser();
                            UserDAO userDAO = new UserDAO();
                            User user1 = userDAO.getUser2(username);
                            String diachi=user1.getDiachi();
                            String dienthoai=user1.getSdt();
                            String email=user1.getEmail();
                            String soCMND=user1.getCmnd();
                            int diem=user1.getPoint();
                           // String hinh=user1.getHinhanh();
                        %> 
                        <p class="a">Giới tính:</p>
                        <p class="b"><select id="sex" name="txtGioitinh">
                                <option  value="0">Nữ</option>
                                <option value="1">Nam</option>
                            </select>
                        </p>
                        <p class="a">Ngày sinh:</p>
                        <p class="b">
                            <select name="Ngay" id="date">
                            <option value="">Ngày</option>
                            <%
                                for (int i = 1; i <= 31; i++) {
                            %>
                            <option  value="<%=i%>"><%=i%> </option>
                            <%
                                }
                            %>
                            </select>
                            <select name="Thang" id="month">
                                <option  value="">Tháng</option>
                                <%
                                    for (int i = 1; i <= 12; i++) {
                                %>
                                <option value="<%=i%>"><%=i%> </option>
                                <%
                                    }
                                %>
                            </select>


                            <select name="Nam" id="year">
                                <option value="">Năm</option>
                                <%
                                    for (int i = 1920; i <= 2013; i++) {
                                %>
                                <option value="<%=i%>"><%=i%> </option>
                                <%
                                    }
                                %>
                            </select>
                        </p>
                        <p class="a">Địa chỉ:</p>
                        <p class="b">
                            <input type="text" name="txtDiachi" value="<%=diachi %>"/>
                            <select name="txtThanhpho" id="txtThanhpho" onchange="get_Quanhuyen();" >
                            <option>Chọn thành phố</option>
                            <%
                                ThanhphoDAO A = new ThanhphoDAO();
                                Thanhpho[] B = A.getAllThanhpho();
                                for (int i = 0; i < B.length; i++) {
                            %>
                            <option  value= <%=B[i].getIdThanhpho()%> > <%=B[i].getThanhpho()%></option>
                            <%
                                }
                            %>
                            </select>
                            <div id="txtQuanhuyen" name="txtQuan"></div>
                        </p>
                        <p class="a">Điện thoại:</p>
                        <p class="b"><input name="txtDienthoai" value="<%=dienthoai %>"/></p>
                        <p class="a">Email:</p>
                        <p class="b">
                            <input value="<%=email %>" name="txtEmail" id="txtEmail" onBlur="check_email();"/>
                            <div id="ck_email"></div>
                        </p>
                        <p class="a">Số CMND:</p>
                        <p class="b">
                            <input name="txtSoCMND" value="<%=soCMND %>"/>
                        </p>
                        <p class="a">Điểm: <%=diem %></p>
                        
                        <input value="Update" name="action" type="submit" class="d"/>
                        <input value="Hủy bỏ" type="reset"  name="reset" class="d"/>
                        </form>
                    </div>
                </div>
                    
            </div>
            <!phan cuoi trang>
            <div class="footer">
                <div class="footerleft"></div>
                <div class="footerright"></div>
            </div>


    </body>
</html>
